from pygame.locals import *

POINT_UP=1
POINT_DOWN=2
POINT_RIGHT=3
POINT_LEFT=4
 
class Point:
    x = None
    y = None
    dir = None
    
    def __init__(self, px = None , py = None , pdir = None ):
        self.x = px
        self.y = py
        self.dir = pdir
    
    def move_down(self, distance ):
        self.y = self.y + distance
    
    def move_up(self, distance):
        self.y = self.y - distance
        
    def move_right(self, distance):
        self.x = self.x + distance
        
    def move_left(self, distance):
        self.x = self.x - distance
        
    def change_dir(self, direction ):
        old_dir = self.dir
        if direction == K_UP:
            self.dir = POINT_UP
        # amit - do all rest ''' 
        if direction == K_DOWN:
            self.dir = POINT_DOWN
        if direction == K_LEFT:
            self.dir = POINT_LEFT
        if direction == K_RIGHT:
            self.dir = POINT_RIGHT               
        if old_dir != self.dir:
            return True
        else:
            return False

        
        
    def move(self, distance):
        if ( self.dir == POINT_UP ):
            self.move_up(distance)
        if ( self.dir == POINT_DOWN ):
            self.move_down(distance)
        if ( self.dir == POINT_RIGHT):
            self.move_right(distance)
        if ( self.dir == POINT_LEFT):
            self.move_left(distance)
            
                     
    def __eq__(self, other):
        return self.x == other.x and self.y == other.y
    
    def __lt__(self,other):
        return self.y < other.y or ( self.y == other.y and self.x < other.x )
    
    def __gt__ (self,other):
        return self.y > other.y or ( self.y == other.y and self.x > other.x )
    
    def __ge__ (self, other):
        return self.y > other.y or ( self.y == other.y and self.x >= other.x )
        
    def __le__ (self, other):
        return self.y < other.y or ( self.y == other.y and self.x <= other.x )
    
    

if __name__ == '__main__':
    
    print("(1,2) < (2,2) (true)")
    print(Point(1,2) < Point(2,2))
    print("(1,2) < (1,1) (false)")
    print(Point(1,2) < Point(1,1))
    
    print("(1,2) > (2,2) (false)") ## __gt__
    print( Point(1,2) > Point(2,2))
    print("(3,2) > (2,2)")
    print( Point(3,2) > Point(2,2))
    
    print("(1,2) >= (2,2) (false)") ## __ge__
    print( Point(1,2) >= Point(2,2))
    print("(1,2) <= (2,2) (true)") ## __le__
    print( Point(1,2) <= Point(2,2))
    
    list = [Point(1,1), Point(1,2), Point(100,100)]
    print('(4,1) == (4,2)')
    print( Point(4,1) == Point(4,2) )
    print('(4,1) != (4,2)')
    print( Point(4,1) != Point(4,2) )
    print('(4,1) == (4,1)')
    print( Point(4,1) == Point(4,1) )
    print('(4,1) != (4,1)')
    print( Point(4,1) != Point(4,1) )
    print('(1,2) in list? (true)')
    print( Point(1,2) in  list )
    print('(1,6) in list? (false)')
    print( Point(1,6) in  list )
    
    
    
    
    